package com.bbt.dormassistant.controller;

import com.bbt.dormassistant.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;



@Api(tags = "微信登录接口")
@RestController
public class WXLoginController {

    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "使用微信登录(登陆后将自动创建用户信息)")
    @GetMapping(value = "/WXLogin")
     public Map<String,Object> WXLogin(@RequestParam("code") String code,@RequestParam("encryptedData")String encryptedData, @RequestParam("iv") String iv){

            Map<String,Object> map  = new HashMap<>();
            map.put("userId",loginService.WXLogin(code,encryptedData,iv));
            map.put("status",1);
            return map;
    }
}
